﻿using System;
using System.Collections.Generic;
using OpenGL;

namespace System
{
	public partial struct V3G
	{
		public void GLLookTo(V3D T)
		{
			GLU.gluLookAt(((V3D)this).X, ((V3D)this).Y, ((V3D)this).Z, T.X, T.Y, T.Z, 0, 1, 0);
		}
		public void GLDrawSphericOrthoRectangle(double Width, double Height)
		{
			V3D X = (V3D)this;
			V3D A = (V3D)(new V3G(Longitude - Width / 2, Latitude - Height / 2, 0));
			V3D B = (V3D)(new V3G(Longitude + Width / 2, Latitude - Height / 2, 0));
			V3D C = (V3D)(new V3G(Longitude + Width / 2, Latitude + Height / 2, 0));
			V3D D = (V3D)(new V3G(Longitude - Width / 2, Latitude + Height / 2, 0));

			GL.glBegin(GL.GL_QUADS);
			X.GLNorm();
			A.GLDraw();
			B.GLDraw();
			C.GLDraw();
			D.GLDraw();
			GL.glEnd();
		}
		public void GLSetProjection()
		{
			GL.glRotated(Longitude, 0, 1, 0);
			GL.glRotated(-Latitude, 1, 0, 0);
			GL.glTranslated(0, 0, V3G.EarthRadius);
		}
		public V3D TransferEarthLocal(V3G Position)
		{
			V3D P = GetDirection(Position) * GetDist(Position);
			P = UnProject(P);
			return P;
		}
		public V3G TransferEarthGlobal(V3D Position)
		{
			return V3D.Null;
		}
	}
}